from flask import g

# 判断用户是否登录的装饰器
def loginrequired(func):

    def wrapper(*args,**kwargs):
        # 先把用户ID写死方便测试
        # user_id = None
        # user_id = 1
        user_id = g.user_id
        if user_id is None:
            return {"message":"请登录"},401
        elif g.is_refresh_token:
            return {"message":"不要用refresh_token"},403
        else:
            return func(*args,**kwargs)

    return wrapper